Repository navigation
Conversation
Add the project skeleton (package, TypeScript strict ESM, vitest, CI on Linux, macOS and Windows, Apache-2.0 LICENSE and NOTICE, CLAUDE.md and AGENTS.md) and the frozen contracts the sandbox, host adapter, tool and benchmark parts build against. The run path is executable end to end with test fakes: MCP tools/call -> FakeSandbox -> Dispatcher (prepare, static rules, hooks, re-prepare on updated args, commit) -> StaticHostAdapter -> MemoryToolRuntime, with mutation ordering, cancellation, transactions with rollback, output caps with overflow files, and a command hook runner that kills the process group on timeout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Commit a dispatcher-owned deep-frozen copy of each prepared call; deep freeze now descends into objects that are already frozen. - Bound every await on adapter and runtime code by the run's abort signal or a grace: prepare, PostToolUse (which now receives the signal), loadPolicy (the run deadline starts before it), in-flight calls on stop, rollback and dispose. - Kill the command hook's whole process group on every completion path, so a backgrounded descendant cannot outlive the hook. - Send protocol and validation errors through the capped result formatter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… bash Implements the ToolRuntime contract for bash, read, write, edit, grep and glob in src/tools: - Workspace jail: paths resolve to real paths under the session cwd, MCP roots and configured extra roots; traversal, links leaving the roots, Windows alias spellings and NUL bytes are refused. Writes and edits to protected host paths and .git are refused. - Commits re-check what prepare saw: no link at the final component (O_NOFOLLOW plus an fd path check), parent directories unchanged, content hash equal to the prepared before-hash. Writes are atomic (temp file in the same directory, mode kept; creates never replace a file that appeared meanwhile). - Edit uses Turnpack's tolerant matcher (exact, line endings, copied line numbers, trailing whitespace, indentation, punctuation), refusing ambiguous and missing matches with the nearest text. - Transactions journal originals in memory and durably under the state dir (64 MiB cap), roll back without clobbering external changes, and recoverStaleJournals restores journals left by a dead server. - bash runs in its own process group with output caps, kills the group on timeout, abort and exit, and runs under @anthropic-ai/sandbox-runtime (bubblewrap or Seatbelt) when the policy asks for containment. - grep and glob are pure JS with .git, node_modules and .gitignore ignores, and never follow links. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Protected path patterns are built by the host adapter from the session cwd as the host spells it. Paths are checked as real paths, so a cwd reached through a symlink, macOS /var or a Windows 8.3 short name made the patterns miss. Each pattern now also matches with its literal prefix resolved. Tests use native real paths so they agree with the runtime on Windows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Paths resolve component by component with POSIX semantics, so `link/..` is the parent of the link's target; an oracle test checks that a path is accepted exactly when its real path is inside the roots. - Writes and edits check protected patterns on the real path and on every link the resolution went through, and refuse a final-component link. - grep and glob re-check each directory after listing it and open each file without following links, checking the handle is the file at that path, so a directory swapped for a link mid-walk leads nowhere. - grep runs the regular expression in a worker thread with a per-file time budget; an abort or an exhausted budget terminates it. - Commits record dev+ino of the file and its directories at prepare and refuse when any changed; check-and-replace of one path holds a per-path lock and re-checks the abort signal, identity and content hash right before the rename. - Rollback and crash recovery remove files and directories only through real directories strictly inside the roots, never through a link. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
macOS realpath(3) accepts `file/..` that open(2) refuses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The dispatcher now commits a frozen structured clone of the prepared call, so metadata kept by object identity was lost and every write was refused. It is now kept in a bounded map keyed by a digest of the call's id, tool and effect, and taken out at commit, so a prepared write commits once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Validate adapter decisions with a schema, reject non-string tool names and refresh the call summary after a hook rewrite. - Keep overflow output out of non-private state directories and off Windows. - Match path patterns across newlines and treat "..name" as inside a root. - Run a single deadline from the start of the run, counting policy loading, and give the sandbox the time left rounded up. - Roll back only after queued writes and edits end, report a pending rollback, and dispose the journal after the rollback has really finished. - Make the fake sandbox check its deadline before steps and calls, yield between steps, and tie its deadline and sleeps to one signal. - Describe the placeholder runtime the default server serves, with a runnable example. - Resolve in-memory paths against the session cwd and roots (Windows paths included), track file revisions for rollback, and run grep and glob in a stoppable worker thread. - Accept only a single --host option in serve. - Skip spawning a hook whose run was already cancelled and stop recording calls in the default runtime. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Fake runtime: cap concurrent search workers per runtime; extra searches wait in a cancelable queue and a slot is reused only after its worker exits. - Fake runtime: build the search job after a slot is held, send grep content only for files that pass the name filter, and reject a search that would copy more than the text limit. - Fake runtime: count edit occurrences and build the diff without per-match or per-line arrays. - Normalize Windows drive paths in the fake runtime and path patterns, and restore original revisions on rollback. - Run: check the deadline before opening a transaction and word the pending-rollback warning accurately. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…untime Network-share (UNC) paths are not supported: POSIX resolution folds their leading `//` while protected-path patterns keep it, so a protected share could go unrecognized. The fixed root, seeded files, session cwd and roots, and call paths now refuse UNC paths before any call is prepared. Edit and write preparation now size the change from cheap counts first and refuse, before building the edited text or the diff, an edit with more than MAX_EDIT_REPLACEMENTS (50,000) replacements or a diff over MAX_DIFF_LINES (200,000) lines. Changes under the budget produce the same text and diff. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The session roots are checked for network-share (UNC) paths even when a fixed root replaces them, so a UNC session root is refused, not ignored. - setFile and revision refuse UNC paths like every other path entry point. - The diff line budget counts the rows the diff actually has: a text that ends with a line break no longer counts one extra row. Edit preparation works out whether the edited text ends with one from where the replaced occurrences sit, still before building the text or the diff, so diffs of up to MAX_DIFF_LINES rows are prepared and only larger ones refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep POSIX paths with redundant leading slashes local. Return actionable guidance when an edit exceeds the replacement limit. Stop glob after its first extra match and skip setup for cancelled searches.
Match local protection patterns and resolved paths with the same leading-slash normalization. Use one resolved key for in-memory reads, writes and file revisions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
NEEDS_HUMAN on One complete round found 15 blockers, 18 major findings, and 12 minor findings. The remaining blockers include file and Bash containment, rollback of concurrent edits, and ambiguous matches. The loop stopped before committing corrections. The initial and current diff each add 3,001 lines of code, 1,238 lines of tests, and zero lines of docs, excluding 52 lockfile lines. Local typecheck and all five CI jobs passed. Ubuntu skipped four OS containment tests because ripgrep and socat were missing. The macOS job ran all 11 Bash tests. The Windows job skipped the Bash suite. GitHub Actions The following decisions will need a response if the PR reaches technical readiness. The transaction completion issue needs to be resolved first. 🔐 Extra directories apply across sessions
🔐 Writes and edits reject links to files
🔐 Windows requires a supported sandbox for contained Bash
💸 Linux containment needs additional programs
For later. Report when brace expansion reaches its cap, validate that configured roots are directories, revisit case-sensitive Windows directories, and validate journal JSON in the test fixture. Other decisions the review recordedTolerant edits share result categories
Allowed network access uses a proxy
Contained Bash commands can wait for another session
File operations have size limits
An edit that changes no text returns an error
A leading tilde can refer to the account's home directory
Search has a deadline for each file
Large directory searches have a traversal cap
|
|
Decisions recorded for the next review round (the owner reviewed these on 2026-11-19):
|
A successful run returned ok: true while its journal directory still held the manifest, so a crash before the background cleanup let startup recovery undo writes already acknowledged. Transaction.dispose() now commits by renaming the journal directory to <id>.committed and fsyncing the journal root; recovery never undoes such a directory and only deletes it. runScript awaits that commit before returning ok: true. Writes still running after the grace period, or a failed rename, roll the run back; a rename that succeeded with a failed fsync returns TransactionIndeterminate without a rollback. File systems that do not support directory fsync (EINVAL, ENOTSUP, EOPNOTSUPP) get the same guarantee as Windows. Fixes #14. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Bound journal finalization by the run deadline and cancellation; never report success or a rollback that has not happened. - Make finalization settle the same way when called again, and keep a committed record whose flush failed. - Refuse a second journaled write to a file another writer changed; roll back only directories the run created. - Undo crashed runs newest write first, skip protected paths, keep records with unhandled files, and read or delete journals only in a private directory with transaction-shaped names. - Flush the journal directories strictly before a write is authorized. - Create files only through an exclusive hard link; check cancellation last before placing a file; use short temporary names. - Open files non-blocking and stop reading at the byte limit. - Protect canonical targets of literal protected paths and the directories a write creates; stop trimming path input; refuse links as search roots. - Refuse commits without prepared policy metadata, and sandboxed bash when a protected pattern cannot be enforced. - Stop the whole bash command when its cwd is gone; strip startup state from the sandbox bootstrap shell; probe that the sandbox can start; do not report a drained exit as a timeout. - Quote diff paths like git and describe empty file creation; reject overlapping and ambiguous-indentation edit matches and oversized edit results; hide file content from edit misses. - Fix gitignore relative paths and directory negation, skip .git files, apply the glob filter to a single file, and treat invalid UTF-8 as binary. - Require Node >=22.12.0, as the sandbox runtime does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
NEEDS_HUMAN on
The incremental episode ran two confirmation rounds and published one correction commit. It confirmed 27 fixes, including 5 blockers, 13 major findings and 9 minor findings. The final round raised four new blockers and two major findings. The PR went from 3,133 to 3,407 added lines of code and from 1,424 to 1,776 added lines of tests, with zero lines of docs. The correction added 773 lines after trimming, above the 300-line review target. Typecheck, build, and 108 focused local tests passed. All five CI jobs passed. The macOS log shows four containment tests ran. Ubuntu skipped those tests because dependencies were missing. The Windows job skipped the Bash suite. CI run 🔐 A protected name can remove Bash write access to a whole folder
Earlier cardsThe earlier four choices and the owner's note about them are recorded on this PR. Cards, owner's note. Other decisions recorded in this review
For later, agree on how diffs identify a file in an extra root and how recovery can identify which temporary files belonged to a run. |
Summary
The real
ToolRuntime(NodeToolRuntime) behind the P0 dispatcher, plusrecoverStaleJournalsfor the integrator to call at startup.Evidence
src/toolsdid not exist; the server ran onMemoryToolRuntime.After:
npm run verifygreen locally (15 files, 162 tests), including one test per defect from the correctness review (each failed or hung on 204b823). Attack tests, each asserting the outside directory is byte-identical afterwards:../, absolute,~, unicode lookalikes of.., NUL, very long paths, Windows alias spellingsbashmid-run then written through.claude/settings.json,.codex/config.toml,.git/configrefused for write/edit, read allowedstalerecoverStaleJournals; tampered journal pointing outside the roots ignoredsleep 100; abort before start never spawns; output caps; under a read-only bwrap sandboxtouch xfails andxdoes not exist; with network offexec 3<>/dev/tcp/1.1.1.1/80failsdiff.ts: 150 random edits round-trip throughgit applyrunScriptwith this runtime commits edits and rolls a denied transactional run backsandbox dependencies missing: ripgrep (rg) not found; socat not installed; to run them there, CI needssudo apt-get install -y bubblewrap socat ripgrep(workflow not edited). Windows logsbash containment is not supported on win32./var, a symlinked cwd) missed the real path. Patterns now also match with their prefix resolved; a test writes.claude/settings.jsonthrough a symlinked cwd and getsprotected-path.Merge Danger
Door: two-way
Nothing outside
src/toolsimports it yet; the integrator wires it intosrc/server/runtime.ts.Blast Radius: contained
One new runtime dependency (
@anthropic-ai/sandbox-runtime, Apache-2.0, loaded only when bash containment is on).Decisions
MatchStrategynames (line endings and punctuation → whitespace-normalized; copied line numbers and trailing whitespace → line-trimmed; indentation → indentation-flexible): the alternative was extending the frozen contract with Turnpack's names (proposed to the integrator).PolicySnapshot.server &) keep running uncontained.rgfast path for grep (the brief made it optional): identical output with JavaScript regex and our ignore rules could not be guaranteed.~in a path is expanded to the home directory (and then refused unless the home directory is a root), instead of being taken as a folder named~.changedFilesrelative paths compare against the cwd as the host spells it, so they can disagree with real paths under an 8.3 cwd (this runtime's own check covers protection; the relative display is the integrator's call)...after a component that does not exist (e.g.new/../x) is refused, as the operating system would, instead of being normalized away.🤖 Generated with Claude Code